package com.sq.partner.manager.controller;

import com.sq.partner.manager.common.Constants;
import com.sq.partner.manager.common.Result;
import com.sq.partner.manager.mybatis.model.AdjSoaResult;
import com.sq.partner.manager.mybatis.model.GatewayUser;
import com.sq.partner.manager.service.IGatewayLifePolicyListService;
import com.sq.partner.manager.service.LifeDataExportService;
import com.sq.partner.manager.util.LogUtil;
import com.sq.partner.manager.util.Page;
import com.sq.partner.manager.util.SqlUtil;
import com.sq.partner.manager.util.StrUtil;
import org.apache.log4j.Logger;
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
import org.apache.poi.hssf.usermodel.HSSFFont;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.hssf.util.HSSFColor;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.io.OutputStream;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 2022/8/24 15:44
 */
@Controller
	@RequestMapping("/lifeExportJsp")
public class LifeDateExportController {

	@SuppressWarnings("unused")
	private static Logger logger = LogUtil.getLog(GatewayOrderController.class);

	@Resource
	private IGatewayLifePolicyListService lifePolicyListService;
	@Resource
	private LifeDataExportService lifeDataExportService;

	/**
	 * 查询当前用户的权限机构
	 * @param session
	 * @return
	 * @throws Exception
	 */
	@RequestMapping(value = "/queryPrivilegeBranch",method = RequestMethod.POST)
	@ResponseBody
	public Result queryPrivilegeBranch(HttpSession session) throws Exception {
		GatewayUser user=(GatewayUser) session.getAttribute(Constants.SESSION_USER);
		logger.info("当前登录用户的userCode为"+user.getUserCode()+",DepartmentStr:"+user.getDepartmentStr());

		if(null != user && StrUtil.isNotEmpty(user.getDepartmentStr())){
			return Result.data(lifePolicyListService.queryPrivilegeBranch(user.getDepartmentStr()));
		}

		return Result.fail();
	}

	@RequestMapping(value = "/index", method = RequestMethod.GET)
	public String index(){
		return "transManager/lifeDataExport";
	}

	@RequestMapping(value="/queryNlifeDateByCriteria")
	public @ResponseBody Page<Map<String,Object>> queryOrderPageByCriteria(HttpSession session, Integer pageIndex, String privilegeBranch, String partnerNo, String dptCde, Integer selectType,
																		   String lifePlanCode, String prodInstCode, String polSubDateBegin,
																		   String polSubDateEnd,String policyNo) throws Exception{
		Map<String, Object> map = new HashMap<String, Object>();
		Page<Map<String,Object>> page = new Page<Map<String, Object>>();
		//TODO  是否应该校验权限
		//Page<Map<String,Object>> page = checkOutBeforeQueryOrder(session, pageIndex, privilegeBranch);
		if(StrUtil.isNotEmpty(polSubDateBegin)){
			polSubDateBegin = polSubDateBegin + "00:00:00";
		}
		if(StrUtil.isNotEmpty(polSubDateEnd)){
			polSubDateEnd = polSubDateEnd + "23:59:59";
		}

		if(pageIndex != -1){
			page.setCurrent(pageIndex);
			map = SqlUtil.buildPageMap(page);
		}
		map.put("pageIndex",pageIndex);
		map.put("privilegeBranch",privilegeBranch);
		map.put("partnerNo",partnerNo);
		map.put("dptCde",dptCde);
		map.put("selectType",selectType);
		map.put("lifePlanCode",lifePlanCode);
		map.put("policyNo",policyNo);
		map.put("prodInstCode",prodInstCode);
		map.put("subDateBegin",polSubDateBegin);
		map.put("subDateEnd",polSubDateEnd);
		page.setMap(map);
		page = lifeDataExportService.queryLifeDataByCriteria(page);
		return page;
	}

	@RequestMapping(value = "exportExcel")
	@ResponseBody
	public void exportExcel(HttpServletResponse response, HttpServletRequest request, @RequestParam(defaultValue = "1") Integer pageIndex, String privilegeBranch, String partnerNo, String dptCde, Integer selectType,
							String lifePlanCode, String prodInstCode, String subDateBegin,
							String subDateEnd,String policyNo) throws Exception {
		Map<String, Object> map = new HashMap<String, Object>();
		Page<Map<String,Object>> page = new Page<Map<String, Object>>();
		if(-1 != pageIndex){
			page.setCurrent(pageIndex);
			map = SqlUtil.buildPageMap(page);
		}
		map.put("pageIndex",pageIndex);
		map.put("privilegeBranch",privilegeBranch);
		map.put("partnerNo",partnerNo);
		map.put("dptCde",dptCde);
		map.put("selectType",selectType);
		map.put("lifePlanCode",lifePlanCode);
		map.put("policyNo",policyNo);
		map.put("prodInstCode",prodInstCode);
		map.put("subDateBegin",subDateBegin);
		map.put("subDateEnd",subDateEnd);
		map.put("isExc",true);
		page.setMap(map);
		Page pageList = lifeDataExportService.queryLifeDataByCriteria(page);
		List<Map<String, Object>> list = pageList.getData();
		String[] fileNames = {"签单时间信息表","实收时间信息表","批增时间信息表","退保时间信息表","魔方产品信息表"};
		String fileName = fileNames[selectType-1];
		String sheetName = "意健险信息";
		// 列数
		int columnNumber = 0;
		// 列宽
		ArrayList<Integer> columnWidth = new ArrayList<Integer>();
		ArrayList<String> columnName = new ArrayList<String>();
		if (selectType == 1){
			columnNumber = 23;
			columnWidth = new ArrayList<Integer>(Arrays.asList(5, 15, 20, 30, 20, 35, 20, 15, 20, 15, 35, 25, 50, 20, 20, 20, 20, 20, 20,20,20,20,20));
			columnName = new ArrayList<String>(Arrays.asList("序号","机构代码","渠道代码", "机构名称", "渠道名称","保单号", "投保人姓名", "被保人姓名","被保人身份证","被保人电话","批增单号（针对魔方产品）","投保方案号", "投保方案名称", "4位产品代码", "保单状态","保单承保时间", "保单保险起期", "保单保险止期", "批增单申请时间", "批增单生效时间","批增前签单保费","批增后签单保费（针对魔方产品）","保单新保/续保标识"));
		}else if(selectType == 2){
			columnNumber = 23;
			columnWidth = new ArrayList<Integer>(Arrays.asList(5, 15, 20, 30,20, 35, 30, 15, 50, 15, 25, 25, 20, 20, 20, 20, 20, 20, 20, 35, 20, 20, 20));
			columnName = new ArrayList<String>(Arrays.asList("序号","机构代码","渠道代码","机构名称", "渠道名称","保单号", "批增单号（针对魔方产品）","投保方案号", "投保方案名称", "4位产品代码", "保单状态","缴费状态", "保单承保时间", "保单保险起期", "保单保险止期", "批增前签单保费", "批增后签单保费（针对魔方产品）","分期实收期次","分期本期实收用户金额","实收金额对应原单/批单","缴费类型","分期缴费时间","保单新保/续保标识"));
		}else if (selectType == 3) {
			columnNumber = 19;
			columnWidth = new ArrayList<Integer>(Arrays.asList(5, 15, 30, 30,20, 35, 35, 15, 50, 15, 25,20, 20, 20, 20, 20, 20, 20, 20));
			columnName = new ArrayList<String>(Arrays.asList("序号","机构代码","渠道代码","机构名称", "渠道名称","保单号", "批增单号（针对魔方产品）","投保方案号", "投保方案名称", "4位产品代码", "保单状态","保单承保时间", "保单保险起期", "保单保险止期", "批增单申请时间", "批增单生效时间","批增前签单保费","批增后签单保费（针对魔方产品）","保单新保/续保标识"));
		}else if (selectType == 4) {
			columnNumber = 28;
			columnWidth = new ArrayList<Integer>(Arrays.asList(5, 15, 30, 30,20, 35, 35, 15, 20, 15, 25, 25, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20));
			columnName = new ArrayList<String>(Arrays.asList("序号","机构代码","渠道代码","机构名称", "渠道名称","保单号", "退保批减单号","投保方案号", "投保方案名称", "4位产品代码", "保单状态","缴费状态", "保单承保时间", "保单保险起期", "保单保险止期","批增前签单保费","批增后签单保费（针对魔方产品）","分期本期应收期次","应收用户金额","实收金额对应原单/批单","缴费类型","分期缴费时间","分期退费期次","分期退费金额","分期退保生效时间","分期退保申请时间","退保保费变化量","保单新保/续保标识"));
		}else if (selectType == 5) {
			columnNumber = 15;
			columnWidth = new ArrayList<Integer>(Arrays.asList(5, 15, 30, 10,20, 25, 30, 25, 20, 15, 25, 25, 20, 20, 20));
			columnName = new ArrayList<String>(Arrays.asList("序号","机构代码","机构名称","保单是否已升级","渠道代码", "渠道名称","保单号","签单日期", "投保方案号", "4位产品代码","保单保险起期", "批增单申请时间","批改/承保","对应升级生效期次","批增单金额或保单金额"));
		}


		// 序号
		int count = 1;
		List<String[]> tempList = new ArrayList<String[]>();
		if (selectType == 1 ){
			for (Map<String, Object> lifeData : list) {
				tempList.add(new String[]{
						StrUtil.valueOf(count++),StrUtil.valueOf(lifeData.get("dptCde")),StrUtil.valueOf(lifeData.get("channelCode")),StrUtil.valueOf(lifeData.get("deptCname")),StrUtil.valueOf(lifeData.get("channelName")),
						StrUtil.valueOf(lifeData.get("polno")),StrUtil.valueOf(lifeData.get("realName")),StrUtil.valueOf(lifeData.get("bbrRealName")),StrUtil.valueOf(lifeData.get("certiCode")),StrUtil.valueOf(lifeData.get("mobile")),
						StrUtil.valueOf(lifeData.get("endorseNo")),StrUtil.valueOf(lifeData.get("productCode")),StrUtil.valueOf(lifeData.get("planName")), StrUtil.valueOf(lifeData.get("coreProdCode")),
						StrUtil.valueOf(lifeData.get("stateId")),StrUtil.valueOf(lifeData.get("appDate")),StrUtil.valueOf(lifeData.get("beginDate")),
						StrUtil.valueOf(lifeData.get("endDate")),StrUtil.valueOf(lifeData.get("endorseDate")), StrUtil.valueOf(lifeData.get("validDate")),StrUtil.valueOf(lifeData.get("startPremium")),StrUtil.valueOf(lifeData.get("sumPremium")),
						StrUtil.valueOf(lifeData.get("oldPolicyNo"))
				});
			}
		}else if (selectType == 2){
			for (Map<String, Object> lifeData : list) {
				tempList.add(new String[]{
						StrUtil.valueOf(count++),StrUtil.valueOf(lifeData.get("dptCde")),StrUtil.valueOf(lifeData.get("channelCode")),StrUtil.valueOf(lifeData.get("deptCname")),StrUtil.valueOf(lifeData.get("channelName")),
						StrUtil.valueOf(lifeData.get("polno")),StrUtil.valueOf(lifeData.get("endorseNo")),
						StrUtil.valueOf(lifeData.get("productCode")),StrUtil.valueOf(lifeData.get("planName")), StrUtil.valueOf(lifeData.get("coreProdCode")),
						StrUtil.valueOf(lifeData.get("stateId")),StrUtil.valueOf(lifeData.get("payStatus")), StrUtil.valueOf(lifeData.get("appDate")),StrUtil.valueOf(lifeData.get("beginDate")),
						StrUtil.valueOf(lifeData.get("endDate")),StrUtil.valueOf(lifeData.get("startPremium")),StrUtil.valueOf(lifeData.get("sumPremium")),StrUtil.valueOf(lifeData.get("payNo")), StrUtil.valueOf(lifeData.get("planPayFee")),
						StrUtil.valueOf(lifeData.get("policyNo")),StrUtil.valueOf(lifeData.get("extPayNo")),StrUtil.valueOf(lifeData.get("planPayDate")),StrUtil.valueOf(lifeData.get("oldPolicyNo"))
				});
			}
		}else if (selectType == 3) {
			for (Map<String, Object> lifeData : list) {
				tempList.add(new String[]{
						StrUtil.valueOf(count++),StrUtil.valueOf(lifeData.get("dptCde")),StrUtil.valueOf(lifeData.get("channelCode")), StrUtil.valueOf(lifeData.get("deptCname")),StrUtil.valueOf(lifeData.get("channelName")),
						StrUtil.valueOf(lifeData.get("polno")),StrUtil.valueOf(lifeData.get("endorseNo")),
						StrUtil.valueOf(lifeData.get("productCode")),StrUtil.valueOf(lifeData.get("planName")), StrUtil.valueOf(lifeData.get("coreProdCode")),
						StrUtil.valueOf(lifeData.get("stateId")),StrUtil.valueOf(lifeData.get("appDate")),StrUtil.valueOf(lifeData.get("beginDate")),
						StrUtil.valueOf(lifeData.get("endDate")),StrUtil.valueOf(lifeData.get("endorseDate")),StrUtil.valueOf(lifeData.get("validDate")),StrUtil.valueOf(lifeData.get("startPremium")), StrUtil.valueOf(lifeData.get("sumPremium")),
						StrUtil.valueOf(lifeData.get("oldPolicyNo"))
				});
			}
		}else if (selectType == 4) {
			for (Map<String, Object> lifeData : list) {
				tempList.add(new String[]{
						StrUtil.valueOf(count++),StrUtil.valueOf(lifeData.get("dptCde")),StrUtil.valueOf(lifeData.get("channelCode")),StrUtil.valueOf(lifeData.get("deptCname")),StrUtil.valueOf(lifeData.get("channelName")),
						StrUtil.valueOf(lifeData.get("polno")),StrUtil.valueOf(lifeData.get("tbdh")),
						StrUtil.valueOf(lifeData.get("productCode")),StrUtil.valueOf(lifeData.get("planName")), StrUtil.valueOf(lifeData.get("coreProdCode")),
						StrUtil.valueOf(lifeData.get("bdzt")),StrUtil.valueOf(lifeData.get("jfzt")), StrUtil.valueOf(lifeData.get("appDate")),StrUtil.valueOf(lifeData.get("beginDate")),
						StrUtil.valueOf(lifeData.get("endDate")),StrUtil.valueOf(lifeData.get("startPremium")),StrUtil.valueOf(lifeData.get("sumPremium")),StrUtil.valueOf(lifeData.get("payNo")), StrUtil.valueOf(lifeData.get("planPayFee")),
						StrUtil.valueOf(lifeData.get("policyNo")),StrUtil.valueOf(lifeData.get("jflx")),StrUtil.valueOf(lifeData.get("planPayDate")),StrUtil.valueOf(lifeData.get("payNo")),StrUtil.valueOf(lifeData.get("refundFee")),StrUtil.valueOf(lifeData.get("effDate")),
						StrUtil.valueOf(lifeData.get("applyPayDate")),StrUtil.valueOf(lifeData.get("chgSumPremium")),StrUtil.valueOf(lifeData.get("oldPolicyNo"))
				});
			}
		}else if (selectType == 5) {
			for (Map<String, Object> lifeData : list) {
				tempList.add(new String[]{
						StrUtil.valueOf(count++),StrUtil.valueOf(lifeData.get("dptCde")),StrUtil.valueOf(lifeData.get("deptCname")),StrUtil.valueOf(lifeData.get("isHookProduct")),
						StrUtil.valueOf(lifeData.get("channelCode")),StrUtil.valueOf(lifeData.get("channelName")),
						StrUtil.valueOf(lifeData.get("polno")),StrUtil.valueOf(lifeData.get("applyPayDate")),
						StrUtil.valueOf(lifeData.get("productCode")),StrUtil.valueOf(lifeData.get("coreProdCode")),
						StrUtil.valueOf(lifeData.get("beginDate")),StrUtil.valueOf(lifeData.get("endorseDate")),StrUtil.valueOf(lifeData.get("hookProduct")),
						StrUtil.valueOf(lifeData.get("payNo")),StrUtil.valueOf(lifeData.get("planPayFee"))
				});
			}
		}

		String[][] haidaInfos = tempList.toArray(new String[][]{});
		HSSFWorkbook wb = generateHssWorkBook(sheetName, columnNumber, columnWidth, columnName, haidaInfos);
		response.setContentType("application/ms-excel;charset=utf-8");
		String userAgent = request.getHeader("user-agent").toLowerCase();
		if (userAgent.contains("msie") || userAgent.contains("trident") || userAgent.contains("edge")) {
			// IE浏览器
			fileName = URLEncoder.encode(fileName, "UTF-8");
		} else {
			// 非IE浏览器
			fileName = new String(fileName.getBytes("UTF-8"), "iso-8859-1");
		}
		response.setHeader("Content-Disposition", "attachment;filename=" + fileName + ".xls");
		OutputStream os = response.getOutputStream();
		try {
			wb.write(os);
		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			os.close();
		}
	}

	public HSSFWorkbook generateHssWorkBook(String sheetName, int columnNumber, ArrayList<Integer> columnWidth,
											ArrayList<String> columnName, String[][] haidaInfos) {
		HSSFWorkbook wb = new HSSFWorkbook();
		HSSFSheet sheet = wb.createSheet(sheetName);
		for (int i = 0; i < columnNumber; i++) {
			sheet.setColumnWidth(i, columnWidth.get(i) * 256);
		}
		HSSFRow headerRow = sheet.createRow(0);
		// 第"0"行行高设置为40
		headerRow.setHeightInPoints(40);
		// 表头单元格样式
		HSSFCellStyle headerStyle = wb.createCellStyle();
		// 设置自动换行
		headerStyle.setWrapText(true);
		// 居中样式
		headerStyle.setAlignment(HSSFCellStyle.ALIGN_CENTER);
		headerStyle.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);
		headerStyle.setBottomBorderColor(HSSFColor.BLACK.index);
		headerStyle.setBorderBottom(HSSFCellStyle.BORDER_MEDIUM);
		headerStyle.setBorderLeft(HSSFCellStyle.BORDER_MEDIUM);
		headerStyle.setBorderRight(HSSFCellStyle.BORDER_MEDIUM);
		headerStyle.setBorderTop(HSSFCellStyle.BORDER_MEDIUM);
		// 设置表头字体样式
		HSSFFont headerFont = wb.createFont();
		headerFont.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
		headerFont.setFontName("宋体");
		// 设置字体大小
		headerFont.setFontHeightInPoints((short) 10);
		headerStyle.setFont(headerFont);

		HSSFCell cell = null;
		for (int i = 0; i < columnNumber; i++) {
			cell = headerRow.createCell(i);
			cell.setCellValue(columnName.get(i));
			cell.setCellStyle(headerStyle);
		}
		HSSFRow row = null;
		// 数据的样式
		HSSFCellStyle style = wb.createCellStyle();
		style.setAlignment(HSSFCellStyle.ALIGN_CENTER);
		style.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);
		style.setBottomBorderColor(HSSFColor.BLACK.index);
		style.setBorderBottom(HSSFCellStyle.BORDER_THIN);
		style.setBorderLeft(HSSFCellStyle.BORDER_THIN);
		style.setBorderRight(HSSFCellStyle.BORDER_THIN);
		style.setBorderTop(HSSFCellStyle.BORDER_THIN);
		HSSFFont font = wb.createFont();
		font.setBoldweight(HSSFFont.BOLDWEIGHT_NORMAL);
		style.setFont(font);
		for (int i = 0; i < haidaInfos.length; i++) {
			row = sheet.createRow(i + 1);
			for (int j = 0; j < columnNumber; j++) {
				cell = row.createCell(j);
				row.setHeightInPoints(16);
				cell.setCellValue(haidaInfos[i][j]);
				cell.setCellStyle(style);
			}
		}
		return wb;
	}

	@RequestMapping(value="/queryLifePolicyAll")
	public @ResponseBody Page<Map<String,Object>> queryLifePolicyAll(String privilegeBranch, String partnerNo, String dptCde, Integer selectType,
																		   String lifePlanCode, String prodInstCode, String polSubDateBegin,
																		   String polSubDateEnd,String policyNo) throws Exception{
		Map<String, Object> map = new HashMap<String, Object>();
		Page<Map<String,Object>> page = new Page<Map<String, Object>>();
		//TODO  是否应该校验权限
		//Page<Map<String,Object>> page = checkOutBeforeQueryOrder(session, pageIndex, privilegeBranch);
		if(StrUtil.isNotEmpty(polSubDateBegin)){
			polSubDateBegin = polSubDateBegin + "00:00:00";
		}
		if(StrUtil.isNotEmpty(polSubDateEnd)){
			polSubDateEnd = polSubDateEnd + "23:59:59";
		}

		map.put("privilegeBranch",privilegeBranch);
		map.put("partnerNo",partnerNo);
		map.put("dptCde",dptCde);
		map.put("selectType",selectType);
		map.put("lifePlanCode",lifePlanCode);
		map.put("policyNo",policyNo);
		map.put("prodInstCode",prodInstCode);
		map.put("subDateBegin",polSubDateBegin);
		map.put("subDateEnd",polSubDateEnd);
		page.setMap(map);
		page = lifeDataExportService.queryLifePolicyAll(page);
		return page;
	}

	/**
	 * 查询订单之前，校验当前用户只能查询其所属机构及其以下机构的订单
	 * @param session
	 * @param pageIndex
	 * @param order
	 * @param privilegeBranch
	 * @return
	 * @throws Exception
	 */
//	public Page<Map<String,Object>> checkOutBeforeQueryOrder(HttpSession session, Integer pageIndex,
//															 GatewayOrder order,String privilegeBranch) throws Exception{
//
//		//获取当前登录用户信息
////		GatewayUser user = (GatewayUser)session.getAttribute(Constants.SESSION_USER);
//
//		Page<Map<String,Object>> page = new Page<Map<String,Object>>();
//		page.setCurrent(pageIndex);
//
////		Map<String,Object> map = new HashMap<String, Object>();
//		Map<String,Object> map = SqlUtil.buildPageMap(page);
//
//		//机构验证
//		if(StrUtil.isEmpty(privilegeBranch)){
//			throw new AppException("系统异常：机构不能为空");
//		}else{
//			if(!(channelInfoConfigService.checkIsHasPrivilege(session, privilegeBranch))){
//				throw new AppException("用户权限不足");
//			}
//		}
//		map.put("privilegeBranch",privilegeBranch);
//
//		//交易起始、终止日期
//		String beginDate = order.getTransDateBegin();
//		String endDate = order.getTransDateEnd();
//
//		if(StrUtil.isNotEmpty(beginDate)){
//			beginDate = beginDate + "00:00:00";
//		}
//		if(StrUtil.isNotEmpty(endDate)){
//			endDate = endDate + "23:59:59";
//		}
//
//		map.put("transDateBegin", beginDate);
//		map.put("transDateEnd", endDate);
//
//		//合作伙伴代码
//		GatewayChannelInfo channelInfo = new GatewayChannelInfo();
//		channelInfo.setDeptCode(privilegeBranch);
//		List<Map> channelInfoList = gatewayOrderService.queryChannelInfoList(channelInfo, "all");
//		if(null == channelInfoList || channelInfoList.size() == 0){
//			page.setResult("noChannelInfo");
//			return page;
//		}
//
//		String channelCodeStr;
//		if(StrUtil.isEmpty(order.getPartnerNo())){
//			channelCodeStr = "";
//		}else{
//			List<String> channelCodeList = new ArrayList<String>();
//			for (Map m : channelInfoList) {
//				channelCodeList.add(m.get("CHANNELCODE").toString());
//			}
//			if(!channelCodeList.contains(order.getPartnerNo())){
//				page.setResult("error");
//				page.setMessage("合作伙伴["+order.getPartnerNo()+"]没有权限执行此操作");
//				return page;
//			}
//			channelCodeStr=order.getPartnerNo();
//		}
//		map.put("channelCodeStr", channelCodeStr);
//
//		if("00".equals(privilegeBranch)){
//			map.put("isHq", 'Y');
//		}else{
//			map.put("isHq", 'N');
//		}
//		map.put("partnerSubCode", order.getSubPartnerNo());
//		map.put("ordreNo", order.getOrdreNo());	//订单号
//		map.put("applySeqNo", order.getApplySeqNo());		//外部流水号
//		map.put("status", order.getStatus());				//订单状态
//
//		page.setType(map);
//		return page;
//	}
}
